package teach.day05;

import java.util.HashMap;
import java.util.Map;

//根据键的HashCode来存储数据，遍历取得数据的顺序是随机的，键允许为NULL，值也允许为NULL，不支持线程同步，同一时刻可以有多个线程来写入HashMap中

public class P04HashMapDemo {
    public static void main(String[] args) {
        Map<String, String> contacts = new HashMap<>();
        contacts.put("Tom", "1234");
        contacts.put("Jerry", "5678");
        System.out.println(contacts);
        System.out.println("Calling " + contacts.get("Tom"));
        contacts.put("Tom", "666");
        System.out.println("Calling " + contacts.get("Tom"));
        contacts.remove("Tom");
        System.out.println("Calling " + contacts.get("Tom"));
        contacts.clear();
        System.out.println(contacts);
    }
}
